/**
 * @description 加载模块目录下所有模块
 * @param {string} files 文件
 * @returns {Object} 文件内容对象
 */
export const moduleLoader = files => {
  return files.keys().reduce((modules, modulePath) => {
    const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
    modules[moduleName] = files(modulePath).default
    return modules
  }, {})
}

export const sleep = (time) => {
  return new Promise((resolve) => {
    const timer = setTimeout(() => {
      resolve()
      clearTimeout(timer)
    }, time)
  });
}